package po;

import java.io.Serializable;

public class BookPO implements Serializable {

	private static final long serialVersionUID = 1L;
	
	private int id;
	private String name;
	private String description;
	private String isbn;
	private String author;
	private String press;
	private int publishingYear;
	private CatalogPO catalog;
	private double price;
	private double discount;
	private int quantity;
	
	public BookPO(int id, String name, String description, String isbn,
			String author, String press, int publishingYear, CatalogPO catalog,
			double price, double discount, int quantity) {
		this.id = id;
		this.name = name;
		this.description = description;
		this.isbn = isbn;
		this.author = author;
		this.press = press;
		this.publishingYear = publishingYear;
		this.catalog = catalog;
		this.price = price;
		this.discount = discount;
		this.quantity = quantity;
	}
	
	public BookPO() {
		this.id = 0;
		this.name = "";
		this.description = "";
		this.isbn = "";
		this.author = "";
		this.press = "";
		this.publishingYear = 0;
		this.catalog = new CatalogPO();
		this.price = 0.0;
		this.discount = 1.0;
		this.quantity = 0;
	}

	@Override
	public String toString() {
		return "BookPO [id=" + id + ", name=" + name + ", description="
				+ description + ", isbn=" + isbn + ", author=" + author
				+ ", press=" + press + ", publishingYear=" + publishingYear
				+ ", catalog=" + catalog + ", price=" + price + ", discount="
				+ discount + ", quantity=" + quantity + "]";
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((author == null) ? 0 : author.hashCode());
		result = prime * result + ((catalog == null) ? 0 : catalog.hashCode());
		result = prime * result
				+ ((description == null) ? 0 : description.hashCode());
		long temp;
		temp = Double.doubleToLongBits(discount);
		result = prime * result + (int) (temp ^ (temp >>> 32));
		result = prime * result + id;
		result = prime * result + ((isbn == null) ? 0 : isbn.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result + ((press == null) ? 0 : press.hashCode());
		temp = Double.doubleToLongBits(price);
		result = prime * result + (int) (temp ^ (temp >>> 32));
		result = prime * result + publishingYear;
		result = prime * result + quantity;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		BookPO other = (BookPO) obj;
		if (isbn == null) {
			if (other.isbn != null)
				return false;
		} else if (!isbn.equals(other.isbn))
			return false;
		return true;
	}

	public int getId() {
		return id;
	}

	public String getName() {
		return name;
	}

	public String getDescription() {
		return description;
	}

	public String getIsbn() {
		return isbn;
	}

	public String getAuthor() {
		return author;
	}

	public String getPress() {
		return press;
	}

	public int getPublishingYear() {
		return publishingYear;
	}

	public CatalogPO getCatalog() {
		return catalog;
	}

	public double getPrice() {
		return price;
	}

	public double getDiscount() {
		return discount;
	}

	public int getQuantity() {
		return quantity;
	}

}
